package com.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.order.domain.pojo.Order;
import com.order.domain.pojo.OrderDetail;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 订单表 Mapper 接口
 * </p>
 *
 * @author 小杰大人
 * @since 2025-09-29
 */
public interface OrderMapper extends BaseMapper<Order> {

    long hasPurchasedCourse(Long courseId, Long usersId);

    List<Long> getPurchasedCourseIdsByUserId(Long userId);

    @Select("select id, order_no, user_id, subject, total_amount, pay_amount, payment_type, payment_time, payment_serial_number, status, remark, create_time, time_out , update_time, create_user, update_user, deleted from `order` where order_no = #{orderNo}")
    Order querySelectByOrderNo(String orderNo);

    List<Order> querySelectOrderByUserId(Long userId, byte status);
}
